package com.wxlsoft.excel.core;

import javax.swing.JProgressBar;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.wxlsoft.ui.ProgressController;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class AbstractSheetListener<T> implements ReadListener<T> {

	private final String sheetName;
	
	private final JProgressBar progress;
	
	public AbstractSheetListener(String sheetName, JProgressBar progress) {
		this.sheetName = sheetName;
		this.progress = progress;
	}
	
	@Override
	public void doAfterAllAnalysed(AnalysisContext context) {
		log.info("{} 解析完成", sheetName);
		ProgressController.readProgress(progress);
		doAfter(context);
	}

	protected abstract void doAfter(AnalysisContext context);
	
}
